package com.rw.coco;

import com.rw.coco.api.MiraiGroupMessageHandler;
import com.rw.coco.api.MiraiPrivateMessageHandler;
import com.rw.coco.data.FileCocoDataApi;
import com.rw.coco.logger.MiraiCocoLogger;
import com.rw.coco.reply.PropertiesCocoReplyApi;
import net.mamoe.mirai.console.plugin.jvm.JavaPlugin;
import net.mamoe.mirai.console.plugin.jvm.JvmPluginDescriptionBuilder;

public final class MiraiDiceCoco extends JavaPlugin {
    public static final MiraiDiceCoco INSTANCE = new MiraiDiceCoco();

    private static final String workPath = "D:\\RWdaze\\Test";

    public final Coco coco;

    private MiraiDiceCoco() {
        super(new JvmPluginDescriptionBuilder("com.rw.coco.dice-coco", "1.0-SNAPSHOT")
                .name("DiceCoco")
                .author("RWdaze")
                .build());

        // 构造日志类
        MiraiCocoLogger miraiCocoLogger = new MiraiCocoLogger(getLogger());

        // 生成可可API
        FileCocoDataApi dataApi = new FileCocoDataApi(workPath);
        PropertiesCocoReplyApi cocoReplyApi = new PropertiesCocoReplyApi(miraiCocoLogger);
        coco = new Coco(dataApi, cocoReplyApi, miraiCocoLogger);
    }

    @Override
    public void onEnable() {
        MiraiPrivateMessageHandler.onEnable(coco);
        MiraiGroupMessageHandler.onEnable(coco);
        getLogger().info("Plugin loaded!");
    }
}